package com.yaorange.controller;


import com.yaorange.entry.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class DeptConsumerController {
    //TODO SERVICE
    @Autowired
    private RestTemplate restTemplate;
    //http://127.0.0.1:8001/dept/list
    private static final String REST_URL_PRFIX = "http://microservicecloud-dept";

    @RequestMapping(value = "/consumer/dept/list", method = RequestMethod.GET)
    public List<Dept> list() {
        return restTemplate.getForObject(REST_URL_PRFIX + "/dept/list", List.class);
    }

    @RequestMapping(value = "/object", method = RequestMethod.GET)
    public Object getOject() {
        return restTemplate.getForObject("https://blackhole.m.jd.com/getinfo", Object.class);
    }
}
